package com.mzy.olddate.demo.map;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author mzy
 * @Date 2021/8/22 22:38
 * @Version 1.0
 */

/**
 * 用到的技术点:
 * 1.map.forEach((key,value) -> System.out.println(key+":"+value));
 *  Lamada表达式：->
 * 2.getOrDefault(key,defaultValue)
 * 3.一些特别的性能对比后面再补充
 */
public class MapMethodTest02 {
    public static void main(String[] args) {
        HashMap<String, String> map1 = new HashMap<>();
        map1.put("x", "123");
        map1.put("y", "456");
        map1.put("z", "123");
        map1.put("c", "456");
        map1.put("v", "123");
        map1.put("b", "456");
//        map1.forEach((k,v) -> System.out.println(k+":"+v));
//        map1.forEach((k,v) -> {
//            System.out.println(k+":"+v);
//            System.out.println("长得真别致");
//        }); //代码块
        System.out.println(map1.getOrDefault("x", "默认输出123"));
        System.out.println(map1.getOrDefault("w","默认输出,你是笨蛋么？"));
    }


}
